import Vue from 'vue'

import Element from 'element-ui'

import App from './App'
import store from './store'
import router from './router'
import directive from './directive'

import '@/libs/polyfill/extension'
import '@/libs/polyfill/filters'
import Formatter from '@/libs/framework/formatter'
import pattern from '@/utils/pattern'

import './assets/icons' // icon
import './assets/styles/iconfont.css'
import './permission' // permission control
import {
  parseTime,
  resetForm,
  addDateRange,
  selectDictLabel,
  selectDictLabels,
  download,
  handleTree
} from "@/utils/ruoyi";
import {
  appLoading
} from "@/libs/framework/common";
import Pagination from "@/components/Pagination";
// 自定义表格工具扩展
import RightToolbar from "@/components/RightToolbar"

// 事件总线
Vue.prototype.$base = new Vue({})
// 全局方法挂载
Vue.prototype.parseTime = parseTime
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree
Vue.prototype.appLoading = appLoading

Vue.prototype.msgSuccess = function (msg) {
  this.$message({
    showClose: true,
    message: msg,
    type: "success"
  });
}

Vue.prototype.msgError = function (msg) {
  this.$message({
    showClose: true,
    message: msg,
    type: "error"
  });
}

Vue.prototype.msgInfo = function (msg) {
  this.$message.info(msg);
}

Vue.prototype.notifySuccess = function (msg, title = '成功') {
  return this.$notify({
    title: title,
    message: msg,
    type: 'success'
  });
}
Vue.prototype.notifyError = function (msg, title = '错误') {
  return this.$notify.error({
    title: title,
    message: msg,
  });
}
Vue.prototype.notifyInfo = function (msg, title = '提示') {
  return this.$notify.info({
    title: title,
    message: msg,
  });
}
Vue.prototype.notifyWarning = function (msg, title = '警告') {
  return this.$notify({
    title: title,
    message: msg,
    type: 'warning'
  });
}


// 全局组件挂载
Vue.component('Pagination', Pagination)
Vue.component('RightToolbar', RightToolbar)

Vue.use(directive)

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */
// if (process.env.NODE_ENV === 'production') {
//   const {
//     mockXHR
//   } = require('../mock')
//   mockXHR()
// }

Vue.use(Element, {
  size: localStorage.getItem('size') || 'small' // set element-ui default size
})

import '@/utils/jq'
import '@/utils/fly'
import '@/utils/f7'

import vRometeJs from 'v-remote-js'
Vue.use(vRometeJs)

import './assets/plugins/smart-design/render/dist/FormMaking.css';
import FormMaking from './assets/plugins/smart-design/render'

Vue.use(FormMaking);

import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'
import '@/libs/polyfill/vxe-extension'
VXETable.setup({
  zIndex: 1024
});
Vue.use(VXETable)

import uploader from 'vue-simple-uploader'
Vue.use(uploader)

import FrameworkInstall from '@/libs/framework/install'
Vue.use(FrameworkInstall)

import QmTableColumn from "@/libs/components/qm-table-column";
import QmTableColgroup from "@/libs/components/qm-table-colgroup";
import QmTable from "@/libs/components/qm-table";
import QmWorkflow from "@/libs/components/qm-workflow";
import QmModal from "@/libs/components/qm-modal";
import QmModalButton from "@/libs/components/qm-modal-button";

Vue.component('QmTableColumn', QmTableColumn)
Vue.component('QmTableColgroup', QmTableColgroup)
Vue.component('QmTable', QmTable)
Vue.component('QmWorkflow', QmWorkflow)
Vue.component('QmModal', QmModal)
Vue.component('QmModalButton', QmModalButton)

import './assets/styles/element-variables.scss'

import '@/assets/styles/index.scss' // global css
import '@/assets/styles/ruoyi.scss' // ruoyi css
import '@fortawesome/fontawesome-free/css/all.min.css'
import '@fortawesome/fontawesome-free/css/v4-shims.min.css'

import 'intro.js/introjs.css';

Vue.config.productionTip = false
window.formatter = Formatter;
window.Pattern = pattern.Pattern;
window.Rules = pattern.Rules;

window.vue = new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
